package cloud.xlh.my_system.getter_and_setter.utils;

import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : example
 * @ Author: XuLeHuang
 * @ Date: 2022/10/3 10:50
 * @ Description:
 */
public class ClassFileManager extends ForwardingJavaFileManager {
    JavaClassFileObject getJavaClassObject() {
        return javaClassFileObject;
    }

    private JavaClassFileObject javaClassFileObject;

    ClassFileManager(StandardJavaFileManager standardManager) {
        super(standardManager);
    }

    @Override
    public JavaFileObject getJavaFileForOutput(Location location,
                                               String className, JavaFileObject.Kind kind, FileObject sibling)
            throws IOException {
        this.javaClassFileObject = new JavaClassFileObject(className, kind);
        return this.javaClassFileObject;
    }
}
